package actions;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.SessionAware;

import beans.User;

import com.opensymphony.xwork2.ActionSupport;

import controllers.AbstractController;


public class TestMyDb extends ActionSupport implements SessionAware {

	private static final long serialVersionUID = 1164809814839976523L;

	private static final Logger LOGGER = Logger.getLogger(TestMyDb.class);

	
	// -------------------------------------------------------------
	// Objects
	// -------------------------------------------------------------

	AbstractController controller = new AbstractController();

	private String login;
	private String password;
	private Boolean result;
	private User user;
	
	Map<String, Object> m;
	
	// -------------------------------------------------------------
	// Methods
	// -------------------------------------------------------------

	public String execute() {
//		if(getLogin() != null && !getLogin().isEmpty() && getPassword() != null && !getPassword().isEmpty()){
//			setUser(controller.testMyDb(getLogin(), getPassword()));
//			System.out.println("test user struts");
//			System.out.println(this.user);
//		    m.put("login",login);
//	        m.put("user", user);
//	        
//			return SUCCESS;
//		}
//		else
		setUser(controller.testMyDb(getLogin(), getPassword()));
		System.out.println("test user struts");
		System.out.println(this.user);
		m.put("sLogin",user.getsLogin());
		m.put("sLastName",user.getsLastName());
		m.put("sFirstName",user.getsFirstName());
		m.put("idStatus",user.getIdStatus());
		m.put("bIsActive",user.getbIsActive());
		m.put("idGroup",user.getGroups());
		m.put("idEntity",user.getIdEntity());
		m.put("idRight",user.getIdRight());
		m.put("sAuthentificationType",user.getsAuthentificationType());
        m.put("idUser", user.getIdUser());
        m.put("sMail", user.getsMail());
        
		return SUCCESS;
			//return ERROR;
	}


	public String getLogin() {
		return login;
	}


	public void setLogin(String login) {
		this.login = login;
	}


	public Boolean getResult() {
		return result;
	}


	public void setResult(Boolean result) {
		this.result = result;
	}


	public String getPassword() {
		return password;
	}


	public void setPassword(String password) {
		this.password = password;
	}


	public User getUser() {
		return user;
	}


	public void setUser(User user) {
		this.user = user;
	}


		
	public void setSession(Map<String, Object> m)
    {
        this.m=m;
    }
 
   


}
